<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>管理员管理界面</title>
	<link rel="stylesheet" href="__STATIC__/bs/css/bootstrap.css">
	<script type="text/javascript" src="__STATIC__/bs/js/jquery.min.js"></script>
	<script type="text/javascript" src="__STATIC__/bs/js/bootstrap.js"></script> 
	<link rel="stylesheet" href="__CSS__/admin/adminManage/userList.css">
</head>
<body>

	<h2 class="text-center">管理员用户列表</h2>
	<div class="container content">
		<div class="funbtn">
			<a id="batDel" class="btn btn-danger" href="javascript:void(0)" >批量删除</a>
			<a class="btn btn-info" href="/admin_manage/create">增加用户</a>
		</div>
		<table class="table table-striped table-hover">
			<tr class="success">
				<th>
					<input type="checkbox" id="batDelChoice">
					<label for="batDelChoice"> 全/反选</label>
				</th>
				<th>id</th>
				<th>用户名</th>
				<th>密码</th>
				<th>姓名</th>
				<th>最后登录时间</th>
				<th>添加时间</th>
				<th>操作</th>
			</tr>
				{volist name="list" id="vo" empty="$empty"}
					<tr>
						<td><input type="checkbox" name="choice" value="{$vo.id}">
						<td>{$vo.id}</td>
						<td>{$vo.userName}</td>
						<td>{$vo.passWord}</td>
						<td>{$vo.name}</td>
						<td>{$vo.last_login_time}</td>
						<td>{$vo.create_time}</td>
						<td>
							<a class="btn btn-info btn-sm"  href="/admin_manage/{$vo.id}/edit">修改</a>
							<a class="btn btn-danger btn-sm" href="javascript:void(0)" onclick="del(this,'{$vo.name}','{$vo.id}')">删除</a>
						</td>
					</tr>
				{/volist}
		</table>
		{$list->render()}
	

	</div>

</body>
<script type="text/javascript">
	//单个删除
	function del(obj,name,id){

        if(confirm("你确定要删除用户("+name+")吗？")){


            $.ajax({
				type:'DELETE',
				url:'admin_manage/'+id,
				success:function(data){
				    if(data==1){
				        $(obj).parent().parent().empty();

                    }else{
				        alert("删除失败");
					}
				}
			})

        }
	}
    //批量选中
    $("#batDelChoice").change(function(){
        if(!$("input[name='choice']").prop("checked")){
            $(this).prop("checked",true);
            $("input[name='choice']").prop("checked",true);

        }else{
            $(this).removeProp("checked");
            $("input[name='choice']").removeProp("checked");
        }
    })



    $("#batDel").click(function(){
        var choices=$("input:checked[name='choice']");
        var ids="";
        for(i=0;i<choices.length;i++){
            if(i!=choices.length-1){
                ids+=choices.eq(i).val()+",";
            }else{
                ids+=choices.eq(i).val();
            }
        }
        if(ids==""){
            alert("请勾选要删除的内容！");
            return;

        }
        if(confirm("你确定要删除"+choices.length+"条用户吗？")){

            window.location="/admin_manage_con/batdel?ids="+ids;
        }
    })



</script>
</html>